import { fetchProducts, fetchBuyers, fetchRecalls, fetchUpperReaches, addRecall } from "@/api/trace"
export default {
  namespaced: true, // 封闭
  state: {

  },
  mutations: {

  },
  getters: {

  },
  actions: {
    // 获取摊位管理列表
    async fetchProducts(context, payload) {
      let { businessId,
        productName,
        saleDate } = payload
      try {
        const { data } = await fetchProducts(businessId, productName, saleDate)
        return data
      } catch (err) {
        console.log(err)
      }
    },

    async fetchBuyers(context, payload){
        let { 
            businessId,
            productName,
            saleDate, 
            perPage,
            page,
        } = payload
          try {
            const { data } = await fetchBuyers(businessId, productName, saleDate, perPage, page)
            return data
          } catch (err) {
            console.log(err)
          }
    },

    async fetchRecalls(context, payload){
        let { 
            businessId,
            productName,
            saleDate, 
            perPage,
            page,
        } = payload
          try {
            const { data } = await fetchRecalls(businessId, productName, saleDate, perPage, page)
            return data
          } catch (err) {
            console.log(err)
          }
    },

    async fetchUpperReaches(context, payload){
      let { 
        businessId,
        productName,
        saleDate
    } = payload
      try {
        const { data } = await fetchUpperReaches(businessId, productName, saleDate)
        return data
      } catch (err) {
        console.log(err)
      }
    },

    async addRecall(context, payload){
      let { 
        businessId,
        productName,
        saleDate,
        pushMessage
    } = payload
      try {
        const { data } = await addRecall(businessId, productName, saleDate, pushMessage)
        return data
      } catch (err) {
        console.log(err)
      }
    }
  }
}
